import JSONBigint from 'json-bigint';

export default function ({ taskCreateDataSet, levelType }) {
  return {
    selection: false,
    autoQuery: false,
    paging: false,
    transport: {
      read: () => ({
        url: `/hagd/v1/schedules${levelType}/methods/${taskCreateDataSet.current.get('methodId')}`,
        method: 'get',
        transformResponse(response) {
          try {
            const res = JSONBigint.parse(response);
            return res.methodParams.paramsList;
          } catch (error) {
            return response;
          }
        },
      }),
    },
    fields: [
      { name: 'name', type: 'string', label: '参数名称' },
      {
        name: 'defaultValue', type: 'string', label: '参数值', required: true,
      },
      { name: 'type', type: 'string', label: '参数类型' },
      { name: 'description', type: 'string', label: '参数描述' },
    ],
  };
}
